package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.ChecksetpwdBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.ChecksetpwdCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
/**
*是否设置过登录密码Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Checksetpwd{
	private static ChecksetpwdBean checksetpwdBean;
	private static ChecksetpwdCall checksetpwdCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("是否设置过登录密码Test");
	}

	@Before
	public void caseUp() {
		checksetpwdBean=new ChecksetpwdBean();
		checksetpwdCall=new ChecksetpwdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checksetpwdCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checksetpwd_001() {
		Logger.start(true,"没有登录密码，成功");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			checksetpwdBean.setUserId(user);
			checksetpwdCall.setData(checksetpwdBean);
			checksetpwdCall.callService();
			Logger.verifyEquals("false", checksetpwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checksetpwd_002() {
		Logger.start(true,"有登录密码，成功");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			u.setIsSetPwd(true);
			u.setLoginPwd("1");
			int user = DGUserCallService.UserCreateCall(u);
			checksetpwdBean.setUserId(user);
			checksetpwdCall.setData(checksetpwdBean);
			checksetpwdCall.callService();
			Logger.verifyEquals("true", checksetpwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Checksetpwd_003() {
		Logger.start(true,"登录密码设置错误然后");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			u.setIsSetPwd(true);
			u.setLoginPwd("123123");
			int user = DGUserCallService.UserCreateCall(u);
			checksetpwdBean.setUserId(user);
			checksetpwdCall.setData(checksetpwdBean);
			checksetpwdCall.callService();
			Logger.verifyEquals("true", checksetpwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}